﻿namespace Shanda.DevFx.Security.Web.Pages
{
    using System;
    using System.Web.UI;

    internal class ControlHelper
    {
        public static Control FindControl(Control control, string controlID)
        {
            if (control == control.get_Page())
            {
                return control.FindControl(controlID);
            }
            Control control2 = control;
            Control control3 = null;
            while ((control3 == null) && (control2 != control.get_Page()))
            {
                control2 = control2.get_NamingContainer();
                if (control2 == null)
                {
                    throw new Exception("NoNamingContainer");
                }
                control3 = control2.FindControl(controlID);
            }
            return control3;
        }
    }
}

